$OpenBSD: patch-cmake_install_macros_cmake,v 1.8 2015/10/31 19:40:43 sthen Exp $
--- cmake/install_macros.cmake.orig	Fri Aug  8 18:13:47 2014
+++ cmake/install_macros.cmake	Mon Aug 11 17:35:30 2014
@@ -198,6 +198,36 @@ IF(UNIX)
 ENDIF()
 ENDMACRO()
 
+MACRO(INSTALL_VERSIONED_SYMLINK linkname target destination component)
+IF(UNIX)
+  GET_TARGET_PROPERTY(location ${target} LOCATION)
+  GET_TARGET_PROPERTY(version ${target} VERSION)
+  GET_FILENAME_COMPONENT(path ${location} PATH)
+  GET_FILENAME_COMPONENT(name ${location} NAME)
+  SET(output ${path}/${linkname})
+  ADD_CUSTOM_COMMAND(
+    OUTPUT ${output}
+    COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output}
+    COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
+      ${name}.${version}
+      ${linkname}
+    WORKING_DIRECTORY ${path}
+    DEPENDS ${target}
+    )
+
+  ADD_CUSTOM_TARGET(symlink_${linkname}
+    ALL
+    DEPENDS ${output})
+  SET_TARGET_PROPERTIES(symlink_${linkname} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+  IF(CMAKE_GENERATOR MATCHES "Xcode")
+    # For Xcode, replace project config with install config
+    STRING(REPLACE "${CMAKE_CFG_INTDIR}"
+      "\${CMAKE_INSTALL_CONFIG_NAME}" output ${output})
+  ENDIF()
+  INSTALL(FILES ${output} DESTINATION ${destination} COMPONENT ${component})
+ENDIF()
+ENDMACRO()
+
 IF(WIN32)
   OPTION(SIGNCODE "Sign executables and dlls with digital certificate" OFF)
   MARK_AS_ADVANCED(SIGNCODE)
